<?php

namespace App\Listeners;

use App\Helpers\PayTrait;
use App\Http\Controllers\Miniprograme\SubscribeController;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Modules\Manager\Entities\Manager;

class TradeSuccessListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        if($event->type==config('wechat.notify.mini.TradeSuccess')){
            $order = $event->order;
            $array =  Manager::query()->where('department_id',$order->department)
                ->where('post_id',2)
                ->whereNotNull('openid')
                ->pluck('mobile');
            (new SubscribeController())->OrderStatus($order->openid,'付款成功通知','订单确认','【邦拓租车】订单确认：您预定的'.$order->name.'车辆已确认，稍后为您送出，客服店长电话：'.json_encode($array));
        }
    }
}
